package o;

import android.content.res.ColorStateList;
import android.graphics.PorterDuff.Mode;
import android.graphics.drawable.Drawable;
import android.os.Build.VERSION;
import android.util.Log;
import android.widget.CompoundButton;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import java.lang.reflect.Field;

public final class iq {
    private static boolean ˊ;
    private static Field ॱ;

    public static void ॱ(@NonNull CompoundButton compoundButton, @Nullable ColorStateList colorStateList) {
        if (VERSION.SDK_INT >= 21) {
            compoundButton.setButtonTintList(colorStateList);
        } else if (compoundButton instanceof je) {
            ((je) compoundButton).setSupportButtonTintList(colorStateList);
        }
    }

    public static void ˎ(@NonNull CompoundButton compoundButton, @Nullable Mode mode) {
        if (VERSION.SDK_INT >= 21) {
            compoundButton.setButtonTintMode(mode);
        } else if (compoundButton instanceof je) {
            ((je) compoundButton).setSupportButtonTintMode(mode);
        }
    }

    @Nullable
    public static Drawable ॱ(@NonNull CompoundButton compoundButton) {
        if (VERSION.SDK_INT >= 23) {
            return compoundButton.getButtonDrawable();
        }
        if (!ˊ) {
            try {
                ॱ = CompoundButton.class.getDeclaredField("mButtonDrawable");
                ॱ.setAccessible(true);
            } catch (Throwable e) {
                Log.i("CompoundButtonCompat", "Failed to retrieve mButtonDrawable field", e);
            }
            ˊ = true;
        }
        if (ॱ != null) {
            try {
                return (Drawable) ॱ.get(compoundButton);
            } catch (Throwable e2) {
                Log.i("CompoundButtonCompat", "Failed to get button drawable via reflection", e2);
                ॱ = null;
            }
        }
        return null;
    }
}
